package traveldream.ejb.entities;

import java.io.Serializable;

import javax.persistence.*;

import traveldream.ejb.DTO.TransportationDTO;

import java.sql.Time;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the transportation_mean database table.
 * 
 */
@Entity
@Table(name="transportation_mean")
@NamedQueries({@NamedQuery(name="TransportationMean.findAll", query="SELECT t FROM TransportationMean t WHERE t.Invalid=false"),
@NamedQuery(name="TransportationMean.findArrival", query="SELECT t FROM TransportationMean t WHERE t.Invalid=false AND t.arrival_Place = :arr_place AND t.available_Places >= :n"),
@NamedQuery(name="TransportationMean.findReturn", query="SELECT t FROM TransportationMean t WHERE t.Invalid=false AND t.arrival_Place = :arr_place AND t.departure_Place = :dep_place AND t.departure_Date> :date_goi AND t.available_Places >= :n")
})
public class TransportationMean implements Serializable {
	private static final long serialVersionUID = 1L;
	public static final String FIND_ALL="TransportationMean.findAll";
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;

	@Temporal(TemporalType.DATE)
	@Column(name="`Arrival Date`")
	private Date arrival_Date;

	@Column(name="`Arrival Place`")
	private String arrival_Place;

	@Column(name="`Arrival Time`")
	private Time arrival_Time;

	@Column(name="`Available Places`")
	private int available_Places;

	private String company;

	@Temporal(TemporalType.DATE)
	@Column(name="`Departure Date`")
	private Date departure_Date;

	@Column(name="`Departure Place`")
	private String departure_Place;

	@Column(name="`Departure Time`")
	private Time departure_Time;

	private String name;

	private int price;
	
	private boolean Invalid;
	
	@OneToMany(mappedBy="Arrival_Transport")
	private List<CustomizedPackage> customPackagesArrival;
	
	@OneToMany(mappedBy="Departure_Transport")
	private List<CustomizedPackage> customPackagesDeparture;
	
	@OneToMany(mappedBy="Going")
	private List<GiftList> giftListGoing;
	
	@OneToMany(mappedBy="Return")
	private List<GiftList> giftListReturn;
	
	
	
	public List<GiftList> getGiftListGoing() {
		return giftListGoing;
	}

	public void setGiftListGoing(List<GiftList> giftListGoing) {
		this.giftListGoing = giftListGoing;
	}

	public List<GiftList> getGiftListReturn() {
		return giftListReturn;
	}

	public void setGiftListReturn(List<GiftList> giftListReturn) {
		this.giftListReturn = giftListReturn;
	}

	public boolean isInvalid() {
		return Invalid;
	}

	public void setInvalid(boolean invalid) {
		Invalid = invalid;
	}

	public List<DefaultPackage> getDefaultPackagesArrival() {
		return defaultPackagesArrival;
	}

	public void setDefaultPackagesArrival(
			List<DefaultPackage> defaultPackagesArrival) {
		this.defaultPackagesArrival = defaultPackagesArrival;
	}

	public List<DefaultPackage> getDefaultPackagesDepature() {
		return defaultPackagesDepature;
	}

	public void setDefaultPackagesDepature(
			List<DefaultPackage> defaultPackagesDepature) {
		this.defaultPackagesDepature = defaultPackagesDepature;
	}

	private String type;
	
	@OneToMany(mappedBy="transport_arr")
	private List<DefaultPackage> defaultPackagesArrival;
	
	@OneToMany(mappedBy="transport_dep")
	private List<DefaultPackage> defaultPackagesDepature;


	public TransportationMean() {
	}

	public TransportationMean(TransportationDTO tDTO)
	{
			convertFromDTO(tDTO);
	}
	
	public void convertFromDTO(TransportationDTO tDTO)
	{
		this.name=tDTO.getName();
		this.available_Places=tDTO.getAvailablePlaces();
		this.type=tDTO.getType();
		this.arrival_Time=tDTO.getArrivalTime();
		this.departure_Time=tDTO.getDepartureTime();
		this.arrival_Date=tDTO.getArrivalDate();
		this.departure_Date=tDTO.getDepartureDate();
		this.arrival_Place=tDTO.getArrivalPlace();
		this.departure_Place=tDTO.getDeparturePlace();
		this.company=tDTO.getCompany();
		this.price=tDTO.getPrice();
		this.Invalid=false;
	}
	
	public TransportationDTO convertToDTO()
	{
		TransportationDTO tDTO = new TransportationDTO();
		tDTO.setId(id);
		tDTO.setName(name);
		tDTO.setAvailablePlaces(available_Places);
		tDTO.setType(type);
		tDTO.setArrivalDate(arrival_Date);
		tDTO.setDepartureDate(departure_Date);
		tDTO.setArrivalPlace(arrival_Place);
		tDTO.setDeparturePlace(departure_Place);
		tDTO.setCompany(company);
		tDTO.setPrice(price);
		tDTO.setDepartureTime(departure_Time);
		tDTO.setArrivalTime(arrival_Time);
		return tDTO;
	}
	
	
	
	public List<CustomizedPackage> getCustomPackagesArrival() {
		return customPackagesArrival;
	}

	public void setCustomPackagesArrival(
			List<CustomizedPackage> customPackagesArrival) {
		this.customPackagesArrival = customPackagesArrival;
	}

	public List<CustomizedPackage> getCustomPackagesDeparture() {
		return customPackagesDeparture;
	}

	public void setCustomPackagesDeparture(
			List<CustomizedPackage> customPackagesDeparture) {
		this.customPackagesDeparture = customPackagesDeparture;
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getArrival_Date() {
		return this.arrival_Date;
	}

	public void setArrival_Date(Date arrival_Date) {
		this.arrival_Date = arrival_Date;
	}

	public String getArrival_Place() {
		return this.arrival_Place;
	}

	public void setArrival_Place(String arrival_Place) {
		this.arrival_Place = arrival_Place;
	}

	public Time getArrival_Time(){
		return this.arrival_Time;
	}

	public void setArrival_Time(Time arrival_Time) {
		this.arrival_Time = arrival_Time;
	}

	public int getAvailable_Places() {
		return this.available_Places;
	}

	public void setAvailable_Places(int available_Places) {
		this.available_Places = available_Places;
	}

	public String getCompany() {
		return this.company;
	}

	public void setCompany(String company) {
		this.company = company;
	}

	public Date getDeparture_Date() {
		return this.departure_Date;
	}

	public void setDeparture_Date(Date departure_Date) {
		this.departure_Date = departure_Date;
	}

	public String getDeparture_Place() {
		return this.departure_Place;
	}

	public void setDeparture_Place(String departure_Place) {
		this.departure_Place = departure_Place;
	}

	public Time getDeparture_Time() {
		return this.departure_Time;
	}

	public void setDeparture_Time(Time departure_Time) {
		this.departure_Time = departure_Time;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getPrice() {
		return this.price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public String getType() {
		return this.type;
	}

	public void setType(String type) {
		this.type = type;
	}
}